# import os
from openai import OpenAI

new_line = '\n\n'
new_line2 = new_line + new_line

while True:
    print('==============================')

    print('欢迎来到豆包')

    question = input("请输入问题：")

    print('正在保存问题中')

    with open('db.txt', 'a', encoding='utf-8') as f:
        f.write('问题：' + question + new_line)

    print('正在思考中：1')

    client = OpenAI(
        # 从环境变量中读取您的方舟API Key
        # api_key=os.environ.get("ARK_API_KEY"),
        api_key = 'd7716419-7851-47d4-a6b1-170542cbf39e',
        base_url="https://ark.cn-beijing.volces.com/api/v3",
        )

    print('正在思考中：2')

    completion = client.chat.completions.create(
        # 将推理接入点 <Model>替换为 Model ID
        # model="<Model>",
        model = 'doubao-seed-1-6-250615',
        messages=[
            {"role": "user", "content": question}
        ]
    )
    # 输出
    print(completion.choices[0].message)

    m = str(completion.choices[0].message)

    print('==============================')

    # 内容
    content = completion.choices[0].message.content
    print(content)

    print('==============================')

    # 推理内容
    reasoning_content = completion.choices[0].message.reasoning_content

    print(reasoning_content)

    with open('db.txt', 'a', encoding='utf-8') as f:
        f.write('message：' + new_line)
        f.write(m + new_line2)
        f.write('content：' + new_line)
        f.write(content + new_line2)
        f.write('reasoning_content：' + new_line)
        f.write(reasoning_content + new_line2)

    print('==============================')




#











# d7716419-7851-47d4-a6b1-170542cbf39e